<?php
!defined('M_P') && exit('Forbidden');

InitGP(array('hid'), null, 2);
$SCR = 'info';
$houseService = house::loadClass('house');/* @var $houseService PW_House */
$houseService->setHid($hid);
if (!$houseService->init(true)) {
	Showmsg('该楼盘不存在!');
}
$houseService->setNav();
$houseService->setBanner();
$houseService->updateHits();
$houseinfo = & $houseService->info;
$houseinfo['property_s'] = $houseService->getBitValue($houseinfo['property'], 'property', ',');
$houseinfo['paystatus_s'] = $houseService->getBitValue($houseinfo['paystatus'], 'paystatus', ',');
$houseinfo['buildtype_s'] = $houseService->getBitValue($houseinfo['buildtype'], 'buildtype', ',');
$houseinfo['carport'] = $houseinfo['carport'] == 0 ? '' : $houseinfo['carport'];
$houseinfo['carportfee'] = ($houseinfo['carportfee'] == '0.00') ? '' : $houseinfo['carportfee'];
$houseinfo['cleaningfee'] = ($houseinfo['cleaningfee'] == '0.00') ? '' : $houseinfo['cleaningfee'];
$houseinfo['greenratio'] = ($houseinfo['greenratio'] == '0.00') ? '' : $houseinfo['greenratio'];
$houseinfo['opendate'] && $houseinfo['opendate'] = (!$houseinfo['isdimopendate'] ? get_date($houseinfo['opendate'], 'Y-m-d') : $houseService->getDimDate($houseinfo['opendate']));
$houseinfo['deliverdate'] && $houseinfo['deliverdate']= (!$houseinfo['isdimdeliverdate'] ? get_date($houseinfo['deliverdate'], 'Y-m-d'): $houseService->getDimDate($houseinfo['deliverdate']));
$houseinfo['peripheral'] = str_replace("\n", '<br />', $houseinfo['peripheral']);
$houseinfo['introduction'] = str_replace("\n", '<br />', $houseinfo['introduction']);
$houseinfo['postnum'] = $houseService->getEvaluntionNum();
$developer = $houseService->getDeveloper();

/*评分相关*/
require_once M_P . 'lib/evaluations.class.php';
$pw_evaluation_db = House::loadDB('evaluation');
$pw_evaluation = new PW_Evaluations($pw_evaluation_db);

$starhtml = $pw_evaluation->getStarHtml($hid, $winduid);
list($scorehtml, $scoreinfo, $totalScore, $count) = $pw_evaluation->getScoreHtml($hid);
$count = (int)$count;
$totalScore = (int)$totalScore;
$fullScore = $pw_evaluation->fullScore;
$scoreurl = $houseBaseUrl."q=evaluations&hid=$hid";
$houseBaseUrl = "index.php?m=$m&";
/*点评列表*/
$scoreCount = $pw_evaluation->getScoreTypeCount();
$scoreKeys = $pw_evaluation->getScoreTypeList();
$scoreKeys = implode(',', $scoreKeys);
//$pw_evaluation_db->setDb_perpage(3);
//$conditions = array('hid'=>array($hid,'eq'));
//$evaluations = $pw_evaluation_db->searchHouseEvaluation($conditions,1,'front');


/*团购相关*/
include_once R_P.'data/bbscache/house_config.php';
$groupbuyurl = $houseBaseUrl."q=groupbuy&";
$areaHtml = '<select name="area">';
//empty($acreageField) && ($acreageField = array());
foreach ($house_field['acreage'] as $key => $value) {
	$areaHtml .= '<option value="' . $key . '" >' . $value['value'] . '</option>';
}
$areaHtml .= '</select>';

$budgetHtml = '<select name="budget">';
//empty($budgetField) && ($budgetField = array());
foreach ($house_field['budget'] as $key => $value) {
	$budgetHtml .= '<option value="' . $key . '" >' . $value['value'] . '</option>';
}
$budgetHtml .= '</select>';

if (!file_exists(D_P . 'data/bbscache/house_imagetype.php')) {
	$imageTypeService = House::loadClass('houseimagetype'); /* @var $imageTypeService PW_HouseImageType */
	$imageTypeService->cacheTypes();
}
require_once D_P . 'data/bbscache/house_imagetype.php';
$pageCache = getPageCache('info', $hid);
$pageCache->init();

$basename = $houseBaseUrl.'q=info&hid=' . $hid;
$imageTypeUrl = $houseBaseUrl.'q=album&hid=' . $hid;

$mapurl = $houseBaseUrl."q=housemap&hid=$hid";

//楼盘浏览记录
$houselog = str_replace(",$hid,", ',', GetCookie('houselog'));
$houselog .= ($houselog ? '' : ',') . $hid . ',';
substr_count($houselog, ',') > 11 && $houselog = preg_replace("/[\d]+\,/i", '', $houselog, 3);
Cookie('houselog', $houselog);

/* SEO 相关设置 */
$_defaultSeo = array('title' => $houseinfo['seotitle'] , 'metaDescription' => $houseinfo['seodescription'], 'metaKeywords' => $houseinfo['seokeywords'] );
$_seopage = 'read';
$_seoname = $houseinfo['name'];

require_once (M_P . 'require/header.php');
require_once PrintEot('info');
footer();
?>